[14.0][IMP] shopfloor_reception: Multi company capability#1133
[14.0][IMP] shopfloor_reception: Multi company capability#1133mt-software-de wants to merge 6 commits intoOCA:14.0from
Conversation
|
Hi @JuMiSanAr, @mmequignon, @guewen, @simahawk, @sebalix, |
a46e1fc to
7682920
Compare
| search = self._actions_for("search") | ||
|
|
||
| location = search.location_from_scan(location_name) | ||
| location = search.location_from_scan(location_name, company=picking.company_id) |
There was a problem hiding this comment.
What about
| search = self._actions_for("search") | |
| location = search.location_from_scan(location_name) | |
| location = search.location_from_scan(location_name, company=picking.company_id) | |
| search = self._actions_for("search").with_company(picking.company_id) | |
| location = search.location_from_scan(location_name) |
There was a problem hiding this comment.
i will change it i like your suggestion
There was a problem hiding this comment.
with_company cannot be called on a work component.
@simahawk How would you solve to provide the right company to the env of the component as it affects several search methods in shopfloor
There was a problem hiding this comment.
i will change it i like your suggestion
I will give it a try tomorrow by extending shopfloor.search.action
There was a problem hiding this comment.
@mt-software-de You could modify shopfloor base service with something like this to define with_company
@property
def company(self):
if self._company is None:
return self.env.company
return self._company
@contextmanager
def with_company(self, company):
try:
self._company = company
yield
finally:
self._company = None
def _actions_for(self, usage, **kw):
return get_actions_for(self, usage, company=self.company, **kw)
You would need to initialize in an init method _company = None in that base service
In the action, you could then retrieve the company with self.work.company instead of using self.env.company
There was a problem hiding this comment.
Since there was a new issue in the checkout scenario, i changed the approach.
Now the base of all scenarios are changed. base.shopfloor.process.
When _actions_for is called, it tries to set the company from self.work.menu.picking_type_ids.company,
this ensures that the env has the right company set.
Maybe it is possible to set already in __init__, but i didn't checked. The first tests on our side worked.
IMO. Its better to have the right company in the env already instead of passing it. Or using a new property.
cc @jbaudoux
Search locations for company of picking type. Create lots with company of picking type.
Depends on #1131
cc @i-vyshnevska @raumschmiede-joshuaL @jbaudoux